/*
 * Problem: K-th Number(POJ 3468)
 * Created: 2022/03/02
 * Author: Yuanshun L
 * Algorithm: 线段树
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int MAX_N = 1e5 + 5;
const int MAX_M = 5e3 + 5;
const int MAX_NODE = (1<<18)-1;

// input
int N,M;
int data[MAX_N]; // raw data
int nums[MAX_N]; // data is sorted
int L[MAX_M],R[MAX_M],K[MAX_M]; // query

vector<int> tree[MAX_NODE];



// 构建线段树
void create(int k,int l,int r){
    if(r-l == 1){
        tree[k].push_back(data[l]);
    }
    else{
        int mid = (l+r)/2;
        int chl = k*2+1,chr = k*2+2;
        create(chl,l,mid);
        create(chr,mid,r);
        tree[k].resize(r-l);
        merge(tree[chl].begin(),tree[chl].end(),
              tree[chr].begin(),tree[chr].end(),
              tree[k].begin()
        );
    }
}

// 计算[l,r)区间中不超过x的元素个数
int query(int a,int b, int x,int k,int l,int r){
    if(b<=l || a >=r)
        return 0;
    else if(a<=l && b>=r)
        return upper_bound(tree[k].begin(),tree[k].end(),x) - tree[k].begin();
    else{
        int cnt = 0,mid = (l+r)/2;
        cnt += query(a,b,x,2*k+1,l,mid);
        cnt += query(a,b,x,2*k+2,mid,r);
        return cnt;
    }
}

void solve(){
    for(int i=0;i<N;i++) nums[i] = data[i];
    sort(nums,nums+N);

    create(0,0,N);

    for(int i=0;i<M;i++){
        int l = L[i]-1, r = R[i], k = K[i];

        int lb = -1, ub = N-1;
        while(ub-lb >1){
            int mid = (lb+ub)/2;
            int x = nums[mid];

            int cnt = query(l,r,x,0,0,N);
            if(cnt >= k) ub=mid;
            else lb=mid;
        }
        printf("%d\n",nums[ub]);
    }
}


int main(){
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);

    cin >> N >> M;
    for(int i = 0;i < N;i++)
        scanf("%d",&data[i]);
    for(int i = 0;i < M;i++){
        scanf("%d%d%d",&L[i],&R[i],&K[i]);
    }
    solve();
    return 0;
}
